package edu.towson.cosc.cosc455.jaldred.compiler;
import java.util.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.lang.*;
import java.util.Arrays;

public class MyCompiler {


	public static String token;
	public static String content;
	static MyLexicalAnalyzer Lexer;
	static MySyntaxAnalyzer Parser;
	//static MySemanticAnalyzer generator;
	
	public static void main(String[] args) throws FileNotFoundException {
		token = "";
		
		//Read file into string
		Scanner scan = new Scanner(new File(args[0]));  
		scan.useDelimiter("\\Z");  
		content = scan.next(); 
		System.out.println("Reading this file into a string: " + content + "Done reading!");

		//Check that there is 1 arg
		if(args.length != 1){
			System.err.println("Error!");
			System.exit(0);
		}
		
		//check extenstion
		Extention(args[0]);
		
		Lexer = new MyLexicalAnalyzer();
		
		Lexer.getNextToken();
		
		//Parser = new MySyntaxAnalyzer();
		//Parser.lolcode();
		//intialize parse tree array
		//other initializations 
		/*
		
		
		parser.lolcode();
		
		generator = new MySemanticAnalyzer();
		// call Semantic Analyzer
		*/
		
		//write output file
		//clean up?
		
		
	}

	public static void Extention (String filename){
		
		String lolcode = ".lol";
	    boolean retVal;

	    retVal = filename.endsWith( lolcode );
	    if (retVal != true) {
	    	//error with file type
	    	System.out.println("Choose an .lol file!");
			}
	    else {
	    	System.out.println("Correct file type!");

	    }
	      	}
}
